#include "Stack.h"
Stack::Stack(size_t capacity)
{
	int* _a = (int*)malloc(sizeof(int) * capacity);
	if (_a == nullptr)
	{
		exit(1);
	}
	_size = 0;
	_capacity = capacity;;
}
//
//Stack::Stack(const Stack& st)
//{
//	
//}

Stack::~Stack()
{
	if (_a)
	{
		free(_a);
		_a = nullptr;
		_size = 0;
		_capacity = 0;
	}
}

void Stack::Pop()
{
	assert(_a);
	--_size;
}


void Stack::Push(int x) 
{
	CheckCapacity();
	_a[_size++] = x;
}


int Stack::Top()
{
	return _a[_size - 1];
}


bool Stack::Empty()
{
	return _size == 0;
}

int Stack::Size()
{
	return _size;
}

//Stack& Stack::operator=(Stack& st)
//{
//	
//}
